<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <style type="text/css">
		body{
			background-image:url(static/img/beij.png);
			background-repeat: no-repeat;
			background-attachment: fixed;
			background-size: cover;
			background-color: wheat;
		}
		#user_reg{
			font-size: 40px;
			text-align: center;
			margin-top: 200px;
		}
		form{
			width: 500px;
			margin: 40px auto auto auto;
			font-size: 25px;
		}
		input{
			height: 30px;
			width: 12em;
			margin-top: 5px;
			margin-bottom: 5px;
		}

    </style>
</head>
<script src="/static/js/jquery.min.js" type="text/javascript"></script>
<body>
  	<div id="user_reg">修改密码</div>
	<form method="post" name="form" >
		<table>
            <tr>
				<td>请输入用户名：</td>
				<td><input id="username" type="text"   placeholder="请输入用户名" ></td>

			</tr>
            <tr>
				<td>请输入手机号：</td>
				<td><input id="phone" type="text"   placeholder="请输入账户绑定手机号" ></td>

			</tr>
			<tr>
				<td>请输入密码：</td>
				<td><input id="password_1" type="password"   placeholder="请输入新密码" ></td>

			</tr>
			<tr>
				<td>请确认密码：</td>
				<td><input id="password_2" type="password" placeholder="请确认密码" ></td>

			</tr>
			<tr>
				<td></td>
				<td ><input type="button" id="submit_form" value="提交" onclick="forget()">
				</td>
			</tr>

		</table>

	</form>
</body>
    <script>
        function forget(){
            var username = $('#username').val();
            var phone = $('#phone').val();
            var password_1 = $('#password_1').val();
            var password_2  = $('#password_2').val();
            var post_data = {
                            'username':username,
                            'phone':phone,
                            'password_1':password_1,
                            'password_2':password_2,
                            };
            console.log(post_data);
            $.ajax({
                url:'http://127.0.0.1:8000/v1/forget',
                type:'put',
                data:JSON.stringify(post_data),
                contentType:'application/json',
                dataType:'json',
                success:function(res){
                    if(res.code == 200){
                        //window.localStorage.setItem('dnblog_token',res.data.token);
                        //window.localStorage.setItem('dnblog_user',res.username);
                        alert('修改成功');
                    }else{
                        alert(res.error);
                    }
			    }
		    })

        }


    </script>
</html>